package comWorld.user.admin.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import comWorld.user.UserContactInfo;
import comWorld.user.UserInfo;
import comWorld.user.manage.UserInfoManage;

/**
 * Servlet implementation class Profile
 */
@WebServlet("/admin/profile")
public class Profile extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public Profile() {
        super();
    }

	/**
	 * @see HttpServlet#service(HttpServletRequest request, HttpServletResponse response)
	 */
	public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		HttpSession session = request.getSession();
		UserInfo userInfo = (UserInfo) session.getAttribute("visitorInfo");
		UserContactInfo conInfo = (UserContactInfo) session.getAttribute("visitorContactInfo");
//		boolean flag = true;
//		if (conInfo != null && conInfo.getId() == userInfo.getId()) {
//			flag = false;
//		}
//		if (flag) {
//			conInfo = UserInfoManage.getUserContactInfo(userInfo.getId());
//			session.setAttribute("visitorContactInfo", conInfo);
//		}
		request.setAttribute("userContactInfo", conInfo);
		
		request.getRequestDispatcher("/user/spaceAdmin/profile.jsp").forward(request, response);
	}

}
